
Page({
  data:{
    v: Math.random(),
    webViewShow: false,
    url: 'http://www.litecoder.com/test.html',
    messageData: []
  },
  onLoad(ops) {
    let { v } = this.data
    let { url } = ops
    url = decodeURIComponent(url)
    url = (url.indexOf('?') === -1) ? `${url}?v=${v}` : `${url}&v=${v}`
    this.setData({
      url,
      webViewShow: true
    })
    console.log(url)
  },
  // // url加密
  // encodeURIComponent(url) {
  //   return encodeURIComponent(url)
  // },
  // // url解码
  // decodeURIComponent(url) {
  //   return decodeURIComponent(url)
  // },
  onMessage(e) {
    let { detail } = e
    this.setData({
      messageData: detail.data[detail.data.length - 1]
    })
  },
  onShareAppMessage(options) {
    let { webViewUrl } = options
    let { messageData } = this.data
    console.log(webViewUrl)
    console.log(messageData)
  }
})